package team.lourd.network.system.own.service.imp;

import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import team.lourd.network.system.batch.ext.BaseCoreHandler;
import team.lourd.network.system.own.service.TestNEModelService;

import java.util.HashMap;
import java.util.Map;

/**
 * 预处理模型网元测试 - service实现类
 *
 * @author JADemo
 * @date 2019/2/27 23:05
 */
@Service
public class TestNEModelServiceImpl implements TestNEModelService {
    // 基本网元处理器
    private BaseCoreHandler baseCoreHandler;

    {
        baseCoreHandler = BaseCoreHandler.getBaseCoreHandler();
    }

    // 逐步处理
    @Override
    public Object stepRun(String command, String jsonStr) {
        Map<String,Object> map;
        if(!StringUtils.isEmpty(jsonStr)){
            map = JSONObject.fromObject(jsonStr);
        }else{
            map = new HashMap<>();
        }
        return baseCoreHandler.step(command, map);
    }
    // 逐步判断
    @Override
    public Boolean stepJudge(String condition, String jsonStr) {
        Map<String,Object> map;
        if(!StringUtils.isEmpty(jsonStr)){
            map = JSONObject.fromObject(jsonStr);
        }else{
            map = new HashMap<>();
        }
        return baseCoreHandler.stepCondition(condition, map);
    }
}
